// Copyright (c) Microsoft Corporation.  All rights reserved.
#include "Common.h"

EXTERN_C const IID IID_ITextServices = { // 8d33f740-cf58-11ce-a89d-00aa006cadc5
    0x8d33f740,
    0xcf58,
    0x11ce,
    {0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5}
  };

EXTERN_C const IID IID_ITextHost = { /* c5bdd8d0-d26e-11ce-a89e-00aa006cadc5 */
    0xc5bdd8d0,
    0xd26e,
    0x11ce,
    {0xa8, 0x9e, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5}
  };

EXTERN_C const IID IID_ITextEditControl = { /* f6642620-d266-11ce-a89e-00aa006cadc5 */
    0xf6642620,
    0xd266,
    0x11ce,
    {0xa8, 0x9e, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5}
  };
  
CTextHost::CTextHost()
{
    m_dwPropBits = TXTBIT_MULTILINE | TXTBIT_RICHTEXT;
}

CTextHost::~CTextHost()
{
}

HDC CTextHost::TxGetDC()
{
    return NULL;
}

INT CTextHost::TxReleaseDC(HDC hdc)
{
    UNREFERENCED_PARAMETER(hdc);
    
    return 0;
}

BOOL CTextHost::TxShowScrollBar(INT fnBar, BOOL fShow)
{
    UNREFERENCED_PARAMETER(fnBar);
    UNREFERENCED_PARAMETER(fShow);
    
    return FALSE;
}

BOOL CTextHost::TxEnableScrollBar(INT fuSBFlags, INT fuArrowflags)
{
    UNREFERENCED_PARAMETER(fuSBFlags);
    UNREFERENCED_PARAMETER(fuArrowflags);
    
    return FALSE;
}

BOOL CTextHost::TxSetScrollRange(INT fnBar, LONG nMinPos, INT nMaxPos, BOOL fRedraw)
{
    UNREFERENCED_PARAMETER(fnBar);
    UNREFERENCED_PARAMETER(nMinPos);
    UNREFERENCED_PARAMETER(nMaxPos);
    UNREFERENCED_PARAMETER(fRedraw);
    
    return FALSE;
}

BOOL CTextHost::TxSetScrollPos (INT fnBar, INT nPos, BOOL fRedraw)
{
    UNREFERENCED_PARAMETER(fnBar);
    UNREFERENCED_PARAMETER(nPos);
    UNREFERENCED_PARAMETER(fRedraw);
    
    return FALSE;
}

void CTextHost::TxInvalidateRect(LPCRECT prc, BOOL fMode)
{
    UNREFERENCED_PARAMETER(prc);
    UNREFERENCED_PARAMETER(fMode);
}

void CTextHost::TxViewChange(BOOL fUpdate)
{
    UNREFERENCED_PARAMETER(fUpdate);
}

BOOL CTextHost::TxCreateCaret(HBITMAP hbmp, INT xWidth, INT yHeight)
{
    UNREFERENCED_PARAMETER(hbmp);
    UNREFERENCED_PARAMETER(xWidth);
    UNREFERENCED_PARAMETER(yHeight);
    
    return FALSE;
}

BOOL CTextHost::TxShowCaret(BOOL fShow)
{
    UNREFERENCED_PARAMETER(fShow);
    
    return FALSE;
}

BOOL CTextHost::TxSetCaretPos(INT x, INT y)
{
    UNREFERENCED_PARAMETER(x);
    UNREFERENCED_PARAMETER(y);
    
    return FALSE;
}

BOOL CTextHost::TxSetTimer(UINT idTimer, UINT uTimeout)
{
    UNREFERENCED_PARAMETER(idTimer);
    UNREFERENCED_PARAMETER(uTimeout);
    
    return FALSE;
}

void CTextHost::TxKillTimer(UINT idTimer)
{
    UNREFERENCED_PARAMETER(idTimer);
}

void CTextHost::TxScrollWindowEx(INT dx, INT dy, LPCRECT lprcScroll, LPCRECT lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate, UINT fuScroll)
{
    UNREFERENCED_PARAMETER(dx);
    UNREFERENCED_PARAMETER(dy);
    UNREFERENCED_PARAMETER(lprcScroll);
    UNREFERENCED_PARAMETER(lprcClip);
    UNREFERENCED_PARAMETER(hrgnUpdate);
    UNREFERENCED_PARAMETER(lprcUpdate); 
    UNREFERENCED_PARAMETER(fuScroll);
}

void CTextHost::TxSetCapture(BOOL fCapture)
{
    UNREFERENCED_PARAMETER(fCapture);
}

void CTextHost::TxSetFocus()
{
}

void CTextHost::TxSetCursor(HCURSOR hcur, BOOL fText)
{
    UNREFERENCED_PARAMETER(hcur);
    UNREFERENCED_PARAMETER(fText);
}

BOOL CTextHost::TxScreenToClient(LPPOINT lppt)
{
    UNREFERENCED_PARAMETER(lppt);
    
    return FALSE;
}

BOOL CTextHost::TxClientToScreen(LPPOINT lppt)
{
    UNREFERENCED_PARAMETER(lppt);
    
    return FALSE;
}

HRESULT CTextHost::TxActivate(LONG* plOldState )
{
    UNREFERENCED_PARAMETER(plOldState);
    
    return E_NOTIMPL;
}

HRESULT CTextHost::TxDeactivate(LONG lNewState )
{
    UNREFERENCED_PARAMETER(lNewState);
    
    return E_NOTIMPL;
}

HRESULT CTextHost::TxGetClientRect(LPRECT prc)
{
    UNREFERENCED_PARAMETER(prc);
    
    return E_NOTIMPL;
}

HRESULT CTextHost::TxGetViewInset(LPRECT prc)
{
    UNREFERENCED_PARAMETER(prc);
    
    return E_NOTIMPL;
}

HRESULT CTextHost::TxGetCharFormat(const CHARFORMATW** ppCF)
{
    UNREFERENCED_PARAMETER(ppCF);
    
    return E_NOTIMPL;
}

HRESULT CTextHost::TxGetParaFormat(const PARAFORMAT** ppPF)
{
    UNREFERENCED_PARAMETER(ppPF);
    
    return E_NOTIMPL;
}

COLORREF CTextHost::TxGetSysColor(int nIndex)
{
    UNREFERENCED_PARAMETER(nIndex);
    
    return ::GetSysColor(nIndex);
}

HRESULT CTextHost::TxGetBackStyle(TXTBACKSTYLE* pstyle)
{
    *pstyle = TXTBACK_TRANSPARENT;
    
    return S_OK;
}

HRESULT CTextHost::TxGetMaxLength(DWORD* plength)
{
    *plength = INFINITE;
    
    return S_OK;
}

HRESULT CTextHost::TxGetScrollBars(DWORD* pdwScrollBar)
{
    *pdwScrollBar = 0;
    
    return S_OK;
}
HRESULT CTextHost::TxGetPasswordChar(__out_ecount(1) TCHAR* pch)
{
    UNREFERENCED_PARAMETER(pch);
    
    return S_FALSE;
}

HRESULT CTextHost::TxGetAcceleratorPos(LONG* pcp)
{
    *pcp = -1;
    return S_OK;
}

HRESULT CTextHost::TxGetExtent(LPSIZEL lpExtent)
{
    UNREFERENCED_PARAMETER(lpExtent);
    
    return E_NOTIMPL;
}

HRESULT CTextHost::OnTxCharFormatChange(const CHARFORMATW* pcf)
{
    UNREFERENCED_PARAMETER(pcf);
    
    return S_OK;
}

HRESULT CTextHost::OnTxParaFormatChange(const PARAFORMAT* ppf)
{
    UNREFERENCED_PARAMETER(ppf);
    
    return S_OK;
}

HRESULT CTextHost::TxGetPropertyBits(DWORD dwMask, DWORD* pdwBits)
{
    *pdwBits = m_dwPropBits & dwMask;
    
    return S_OK;
}

HRESULT CTextHost::TxNotify(DWORD iNotify, void* pv)
{
    UNREFERENCED_PARAMETER(iNotify);
    UNREFERENCED_PARAMETER(pv);
    
    return S_OK;
}

HIMC CTextHost::TxImmGetContext()
{
    return NULL;
}

void CTextHost::TxImmReleaseContext(HIMC himc)
{
    UNREFERENCED_PARAMETER(himc);
}

HRESULT CTextHost::TxGetSelectionBarWidth(LONG *lSelBarWidth)
{
    *lSelBarWidth = 0;
    return S_OK;
}

VOID CTextHost::SetWordWrap(BOOL bWordWrap)
{
    if (bWordWrap)
    {
        m_dwPropBits |= TXTBIT_WORDWRAP;
    }
}
